<?php
namespace app\controller;

use app\BaseController;

class addressbook extends BaseController
{ public $contacts;
    
    static function base(){
        $config = [
            'corp_id' => 'xxxxxxxxxxxxxxxxx',
            'secret'   => 'xxxxxxxxxx', // 通讯录的 secret
            //...
        ];
        
        $this->contacts = Factory::work($config);
    }

    public function create()
    {
        $data = [
            "userid" => "overtrue",
            "name" => "超哥",
            "english_name" => "overtrue"
            "mobile" => "1818888888",
        ];
        $this->contacts->user->create($data);
    }

    public function get()
    {
        $this->contacts->user->get('overtrue');

    }

    public function update()
    {
        $contacts->user->delete('overtrue');
        // 或者删除多个
        $contacts->user->delete(['overtrue', 'zhangsan', 'wangwu']);
    }

    public function getDepartmentUsers()
    {
        $contacts->user->getDepartmentUsers($departmentId);
        // 递归获取子部门下面的成员
        $contacts->user->getDepartmentUsers($departmentId, true);
    }

    public function get()
    {

        $contacts->user->getDetailedDepartmentUsers($departmentId);
        // 递归获取子部门下面的成员
        $contacts->user->getDetailedDepartmentUsers($departmentId, true);
    }
}
